package cn.battlecruiser.vishnu.order.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.request.RequestContextHolder;

@RestController
public class OrderController {
	
	
	
	@GetMapping("/info")
	@PreAuthorize("hasAnyRole('ADMIN', 'USER')")
    public String getOrder() {
		return "ok";
    }
	
	@GetMapping("/session")
    public String getSession() {
		SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		RequestContextHolder.getRequestAttributes().getAttributeNames(0);
		return "ok";
    }
	
}
